import { getDesignerInfo, getStaticsConfig } from '@/api/my'
const ERR_OK = 200
export default {
  data () {
    return {
      designerInfo: null,
      config: null
    }
  },
  created () {
    this._getStaticsConfig()
      .then(() => {
        this._getDesignerInfo(this.$route.query.information_id)
      })
  },
  methods: {
    _getDesignerInfo (informationId) {
      return getDesignerInfo(informationId)
        .then(res => {
          if (res.code === ERR_OK) {
            this.designerInfo = res.data
            return Promise.resolve()
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    _getStaticsConfig () {
      return getStaticsConfig()
        .then(res => {
          if (res.code === ERR_OK) {
            res.data.styles.forEach(item => {
              item.is_select = false
            })
            this.config = res.data
            return Promise.resolve()
          }
        })
        .catch(err => {
          console.log(err)
        })
    }
  }
}
